package com.joysuch.wwyt.api.mh.repository;

import com.joysuch.wwyt.api.mh.entity.MhPlatformField;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface MhPlatformFieldDao extends JpaRepository<MhPlatformField, Long> {
    List<MhPlatformField> findByPlatformId(Long id);

    int countByFieldName(String fieldName);

    int countByFieldNameAndPlatformId(String fieldName, Long platformId);

//    @Query(value = "SELECT * FROM `wwyt_mh_platform_field` WHERE create_time BETWEEN ?1 AND ?2", nativeQuery = true)
//    List<MhPlatformField> test(Date date, Date date1);

    @Query(value = "SELECT * FROM wwyt_mh_platform_field WHERE platform_id =?1 AND parent_id IS NULL",nativeQuery = true)
    List<MhPlatformField> findByPlatformIdAndParentIdIsNull(Long id);

    List<MhPlatformField> findByParentId(Long id);

    int countByFieldNameAndPlatformIdAndParentId(String fieldName, Long platformId, Long parentId);
}
